package com.imcode;

import java.io.*;

public class FileCopy02 {
    public static void main(String[] args) throws IOException {
        //1.读取1.txt的文件内容到内存
        Reader fr = new FileReader("file/1.txt");
        Writer fw = new FileWriter("file/3.txt");
        //2.按字符数组取读取
        char[] chars = new char[1024];
        int len = 0;//存储每次读取到的字符的个数
        //3.循环读取1.txt的内容
        while ((len = fr.read(chars)) != -1) {
            //4.将读取到的内容写入到3.txt
            fw.write(chars, 0, len);
        }
        //5.关闭流
        fw.close();
        fr.close();
    }
}
